package com.hantang.devops.appgenerator.core;

import java.util.ArrayList;
import java.util.List;

import com.hantang.devops.appgenerator.core.engine.CodeGenerateChain;
import com.hantang.devops.appgenerator.core.engine.CodeGenerateRequest;
import com.hantang.devops.appgenerator.core.engine.CodeGenerateResponse;
import com.hantang.devops.appgenerator.core.engine.html.HtmlCodeGenerateHandler;
import com.hantang.devops.appgenerator.core.engine.java.JavaCodeGenerateHandler;
import com.hantang.devops.appgenerator.item.bean.ItemBean;
import com.hantang.devops.appgenerator.model.ModelBean;

public class CodeFactoryTest {
	//initialize the generate code configuration
	//00 load the module 
	//01 load the item
	//02 load the rule how to generate code
	//03 load the template 
	
	public static void main(String[] args){
		
		ItemBean item = new ItemBean();
		/*
		 *Item Basic information 
		 */
		item.setItemId("I0000000000000");
		item.setItemName("user name");
		item.setItemDataType("00");//String
		item.setViewType("00");//input
		item.setItemBusinessType("00");//email
		
		ModelBean modle = new ModelBean();
		List<ItemBean> itmes = new ArrayList<ItemBean>();
		itmes.add(item);
		modle.setItmes(itmes);
		CodeGenerateResponse result = new CodeGenerateResponse();
		CodeGenerateRequest request = new CodeGenerateRequest(modle);
		JavaCodeGenerateHandler jHandler = new JavaCodeGenerateHandler();
		
		HtmlCodeGenerateHandler htmlHandler = new HtmlCodeGenerateHandler();
		
		CodeGenerateChain chain = new CodeGenerateChain();
		
		chain.addHandlers(jHandler);
		chain.addHandlers(htmlHandler);
		chain.executeCodeGenerate(request, result);
	}
}
